const { DataTypes } = require('sequelize')
const sequelize = require('../config/database')

const EvaluateModel = sequelize.define('Evaluate', {
  evaluate_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    allowNull: false,
    autoIncrement: true
  },
  user_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  order_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  rating: {
    type: DataTypes.INTEGER,
    allowNull: false,
    validate: {
      min: 1,
      max: 5,
    }
  },
  comment: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  createdAt: {
    type: DataTypes.TIME
  }
}, {
  freezeTableName: true,
  tableName: 'evaluate',
  timestamps: false
})

module.exports = EvaluateModel